<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>首页</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <%@ include file="../include/css.jsp" %>

</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="container ">
    <button class="btn btn-primary" type="button" id="addBtn">添加</button>
    <table class="table text-nowrap table-striped table-hover table-condensed table-condensed" >
        <tbody>
        <tr>
            <td>姓名</td>
            <td>手机号</td>
            <td>权限</td>
        </tr>
        <%--循环迭代list  每次一个tr--%>
        <c:forEach items="${list.list}" var="user">
            <tr>
                <th>
                        ${user.name}
                </th>
                <th>
                        ${user.mobile}
                </th>
                <th>
                        ${user.permissions}
                </th>

                <th>
                    <a href="/user/${user.id}" rel="${user.id}" class="details">详情</a>
                    <a href="/user/update/${user.id}" rel="${user.id}" class="details">编辑</a>
                </th>
            </tr>
        </c:forEach>
        <label ><strong>${list.total}条数据</strong></label>
        <ul id="pagination-demo" class="pagination pull-right"></ul>
        </tbody>
    </table>

</div>

<script
        src="https://code.jquery.com/jquery-2.2.4.min.js"
        integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44="
        crossorigin="anonymous"></script>

<%@ include file="../include/js.jsp"%>
<script>
    $(function () {
        $("#pagination-demo").twbsPagination({
            totalPages:${list.pages},
            visiblePages:3,
            first:'首页',
            last:'末页',
            prev:'上一页',
            next:'下一页',
            href:"/user/all?p={{number}}"
        });

        $(".details").click(function () {
            var id = $(this).attr("rel");
            window.location.href="/user/"+id;
        });


        $("#addBtn").click(function () {
            window.location.href="/user/add";
        })

    });
</script>
</body>
</html>